package com.bzzoneit.newsys.utils.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.bzzoneit.newsys.utils.Constant;

public class SessionInterceptor extends HandlerInterceptorAdapter {

	private static final Logger logger = LoggerFactory.getLogger(SessionInterceptor.class);

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		//System.out.println("进入了拦截器");
//		HttpSession hSession = request.getSession();
//		Long userId = (Long) hSession.getAttribute(Constant.USERID);
//		String password = (String) hSession.getAttribute(Constant.PASSWORD);
//		if (userId == null || password == null) {
//			response.setStatus(403);
//			logger.warn("in response.setStatus(403) , hSession is :" + hSession + " and userId is :" + userId + " and password is :" + password);
//			
//			return false;
//		}
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

	}

	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

	}

}
